var xmlhttp;

// Function sends out for the class list on race change.
function getClasses(race) {
	xmlhttp=GetXmlHttpObject();
	// Pop up error if Browser doesn't support requests.
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	// Generate the url to send to.
	var url="tweaks/roster/member.php";
	url=url+"?race="+race;
	url=url+"&sid="+Math.random();
	
	// Send the request
	xmlhttp.onreadystatechange=classChanged;
	xmlhttp.open("GET", url, true);
	xmlhttp.send(null);
}

// Function recieves the class request and updates the class menu.
function classChanged() {
	if (xmlhttp.readyState==4) {
		//document.member.rclass.innerHTML = xmlhttp.responseText;
		document.getElementById("rclass").innerHTML = xmlhttp.responseText;
	}
}

// Function sends out for the class list on race change.
function getRoles(rclass) {
	xmlhttp=GetXmlHttpObject();
	
	// Pop up error if Browser doesn't support requests.
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	// Generate the url to send to.
	var url = "tweaks/roster/member.php";
	url = url + "?class=" + rclass;
	url = url + "&sid=" + Math.random();
	
	// Send the request
	xmlhttp.onreadystatechange=rolesChanged;
	xmlhttp.open("GET", url, true);
	xmlhttp.send(null);
}

// Function recieves the class request and updates the class menu.
function rolesChanged() {
	if (xmlhttp.readyState==4) {
		document.member.mainspec.innerHTML = xmlhttp.responseText;
		document.member.offspec.innerHTML = xmlhttp.responseText;
	}
}

// Browser specific setup.
function GetXmlHttpObject() {
	if (window.XMLHttpRequest) {
	// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject) {
		// code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}